﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="Equipment.DataAccess" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="CurrentMenuIDContent" runat="server" >configMenu</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Edit Notification Type</h2>
    <br />
    <% Using Html.BeginForm()%>
    <%= Html.ValidationSummary(False) %>
    <fieldset>
        <legend>Notification Type</legend>
        <table>
            <tr>
                <td width="130px">
                    <label for="Id">
                        ID:</label>
                </td>
                <td>
                    <%= Html.Encode(ViewData("ID"))%>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td width="130px">
                    <label for="Id">
                        Notification Name:</label>
                </td>
                <td>
                    <%= Html.TextBox("NotificationName", Nothing, New With {.class = "text"})%>
                    <%= Html.ValidationMessage("NotificationName", "*")%>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="top">
                    <label for="Id">
                        Trigger:</label>
                </td>
                <td class="top">
                    <%= Html.DropDownList("Trigger")%>
                    <%= Html.ValidationMessage("Trigger", "*")%>
                </td>
                <td class="top">
                    <br />
                    <table id="overdueContent"  
                    <%If ViewData("ShowOverdueTable") Is Nothing %>
                    class="hidden"
                    <%End If%>>
                        <% For Each overdue In ViewData("OverdueTypes")%>
                        <tr>
                            <td>
                                <%= Html.RadioButton("rbOverdueType", overdue.Type, CBool(overdue.Selected))%>&nbsp;<%: overdue.Description%>
                            </td>
                            <td>
                                <% If overdue.Selected Then%>
                                X&nbsp;=&nbsp;<%= Html.TextBox(String.Format("txt{0}", overdue.Type.ToString), ViewData("SelectedOverdueValue"), New With {.class = "text"})%>
                                <% Else%>
                                X&nbsp;=&nbsp;<%= Html.TextBox(String.Format("txt{0}", overdue.Type.ToString), Nothing, New With {.class = "text"})%>
                                <% End If%>
                            </td>
                        </tr>
                        <% Next%>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="top">
                    Security Roles:
                </td>
                <td class="top">
                    <table class="data-table">
                        <thead>
                            <tr>
                                <th>
                                    &nbsp
                                </th>
                                <th>
                                    Role
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <% For Each role In ViewData("Roles")%>
                            <tr>
                                <td>
                                    <%= Html.CheckBox(String.Format("cbxRole_{0}", role.ID), ViewData(String.Format("SelectedRole_{0}", role.ID)) IsNot Nothing)%>
                                </td>
                                <td>
                                    <%: role.Description%>
                                </td>
                            </tr>
                            <% Next%>
                        </tbody>
                    </table>
                </td>
                <td>
                </td>
            </tr>
        </table>
        <p>
            <input type="submit" class="button right" value="Save" />
        </p>
    </fieldset>
    <% End Using%>
    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>
    <script type="text/javascript">

        $(document).ready(function () {
            $("select").change(function () {
                var trigger = $("#Trigger").val();
                if (trigger === "WorkOrder_Overdue") {
                    $("#overdueContent").removeClass("hidden");
                }
                else {
                    $("#overdueContent").addClass("hidden");
                }

            });

        });

    </script>
</asp:Content>
